import http from '@/utils/request'

const state = {
  // 组织架构
  organizationData: [],
  // 自定义群组
  userGroupData: []
}

const mutations = {

  GET_ORGAN: (state, data) => {
    state.organizationData = data
  },
  GET_USER_GROUP: (state, data) => {
    state.userGroupData = data
  }
}

const actions = {
  getOrgan({ commit }) {
    http.getHeader('/userAndOrg/getOrg', {
    }).then(res => {
      if (res.data.code === '00') {
        commit('GET_ORGAN', res.data.data)
      }
    })
  },
  getUserGroup({ commit }) {
    http.getHeader('/userGroup/get/userGroup', {
    }).then(res => {
      if (res.data.code === '00') {
        commit('GET_USER_GROUP', res.data.data)
      }
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
